package com.example.twoscroolview.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.example.twoscroolview.R
import com.example.twoscroolview.bean.StartBean
import java.text.FieldPosition

class StickAdapter : BaseQuickAdapter<StartBean, BaseViewHolder>(R.layout.item_recycle_stick) {
    override fun convert(helper: BaseViewHolder?, item: StartBean) {
        helper?.setText(R.id.tv1, item.name)
    }

    /**
     * 是否是组的第一个
     */
    fun isHeadGroup(position: Int): Boolean {

        return if (position == 0) {
            true
        } else {
            val currentGroupName = getGroupName(position)
            val preGroupName = getGroupName(position - 1)
            preGroupName != currentGroupName
        }
    }

    fun getGroupName(position: Int): String {
        return mData.get(position).groupName ?: ""
    }
}